package com.ss.SmartStock.task;

import com.ss.SmartStock.service.ProductService;

public class ProductTask implements Runnable {
    private final ProductService productService;
    private final long productId;  
    private final boolean isOnline; // true表示上线，false表示下线  
  
    public ProductTask(ProductService productService, long productId, boolean isOnline) {  
        this.productService = productService;  
        this.productId = productId;  
        this.isOnline = isOnline;  
    }  
  
    @Override  
    public void run() {  
        if (isOnline) {  
            productService.putProductOnline(productId);
        } else {  
            productService.takeProductOffline(productId);
        }  
    }  
}